<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Messagelist extends Model
{
    protected $table="messagelist";
    public $timestamps=false;
    protected $fillable = [];
    protected $guarded =[];
    
    /**
     * 添加用户信息
     * @param \Illuminate\Http\Request $request
     */
    public static function addMessage(\Illuminate\Http\Request $request, $user) {
        if (!$request->input('Mn_Title', false) || !$request->input("Mn_SendContent", false)) {
            return aaa_return(0, "请填写留言标题、内容");
        }
        $message = new static();
        $message->SendUserId = $user->Mu_Number;
        $message->AcceptUserId = "系统";
        $message->SendTitle = $request->input('Mn_Title');
        $message->SendContent = $request->input("Mn_SendContent");
        $message->SendDate = date("Y-m-d H:i:s");
        $message->MessageStatus = "未处理";
        $message->MessageType = "普通消息";
        $message->SendUserName = $user->Mu_Name;
        $message->save();
        return aaa_return(1, "留言发送成功");
    }
}
